<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><!-- 此页面固定UTF-8编码。不会出现乱码！-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>api.map.baidu.com</title>
<style type="text/css">
html {
	height: 100%
}

body {
	height: 100%;
	margin: 0px;
	padding: 0px
}

#container, #allmap {
	height: 100%
}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=W3F70b5pDWnQS65hRiq3MMUf"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
<!--<script src="http://api.map.baidu.com/library/CityList/1.4/src/CityList_min.js" type="text/javascript" charset="gbk"></script>-->

<script type="text/javascript" src="{$PLSTATIC}dialog417/dialog.js?skin=default"></script>
<script type="text/javascript" src="{$PLSTATIC}dialog417/plugins/iframeTools.js"></script>
<script type="text/javascript" src="{$PLSTATIC}jquery.min.js"></script>

<script type="text/javascript">

var $$ = jQuery.noConflict();

</script>

</head>

<body>
<div style="width:100%">
<div id="citys" style="padding:10px;">
<table width="100%">
<tr><td>
<!--{eval echo lev_base::levdiconv(lev_module::ismodule2('x_citys', '_city', array(1)), CHARSET, 'utf-8');}-->
</td><td style="color:red;font-weight:bold;font-size:12px;">【提示】鼠标右键创建标注</td><td align=right>
<input type="text" name="srhcity" id="srhcity" value="搜索城市" onfocus="if (this.value=='搜索城市') this.value=''" style="width:100px">
<input type="button" value="搜索" onclick="map.centerAndZoom(jQuery('#srhcity').val(), map.getZoom());">
<input type="button" value="我所在城市" onclick="iptocity()">
</td></tr></table>
</div>
</div>
<div id="container"></div>

<script type="text/javascript">

// 百度地图API功能
var map = new BMap.Map("container");            // 创建Map实例
var point = new BMap.Point(116.404, 39.915);  //创建点坐标  
map.centerAndZoom(point, 12);                 //初始化地图，设置中心点坐标和地图级别  
map.addControl(new BMap.NavigationControl());   
</script>
<script type="text/javascript">
iptocity();
function iptocity() {
	var myCity = new BMap.LocalCity();
	myCity.get(myFun);
}
function myFun(result){
    var cityName = result.name;
    map.setCenter(cityName)
}

var content = '<div style="margin:0;line-height:20px;padding:2px;">' +
                '<img src="../img/baidu.jpg" alt="" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' +
                '地址：北京市海淀区上地十街10号<br/>电话：(010)59928888<br/>简介：百度大厦位于北京市海淀区西二旗地铁站附近，为百度公司综合研发及办公总部。' +
              '</div>';
var searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
	title  : "百度大厦",      //标题
	width  : 290,             //宽度
	height : 105,              //高度
	panel  : "panel",         //检索结果面板
	enableAutoPan : true,     //自动平移
	enableSendToPhone: true, //是否启用发送到手机
	searchTypes   :[
		BMAPLIB_TAB_SEARCH,   //周边检索
		BMAPLIB_TAB_TO_HERE,  //到这里去
		BMAPLIB_TAB_FROM_HERE //从这里出发
	]
});

map.addEventListener("click",function(e){
	  //  var point = new BMap.Point(e.point.lng, e.point.lat);
	  //  marker = new BMap.Marker(point);         //创建标注    
	   // addmarkers(marker);
	  //  setmapzb(e.point);
});

//map.addEventListener("tilesloaded",function(){("地图加载完毕");});

</script>


<script type="text/javascript">

var contextMenu = new BMap.ContextMenu();
var txtMenuItem = [
  {
	   text:'在此添加标注',
	   callback:function(p){
		    marker = new BMap.Marker(p), px = map.pointToPixel(p);
		    addmarkers(marker);
		    setmapzb(p);
	   }
 },{
	   text:'放大至最大级',
	   callback:function(){map.setZoom(18)}
 },{
	   text:'移除全部标注',
	   callback:function(){
	        for(var i = 0; i < overlays.length; i++){
	            map.removeOverlay(overlays[i]);
	        }
	        overlays.length = 0
	   }
 },{
	   text:'移除最后一个标注',
	   callback:function(){
		   map.removeOverlay(overlays[overlays.length-1]);
	       overlays.length -= 1;
	   }
 },{
	   text:'查看全国',
	   callback:function(){map.setZoom(4)}
 },{
	   text:'放大',
	   callback:function(){map.zoomIn()}
 },{
	   text:'缩小',
	   callback:function(){map.zoomOut()} 
 }
];


 for(var i=0; i < txtMenuItem.length; i++){
  contextMenu.addItem(new BMap.MenuItem(txtMenuItem[i].text,txtMenuItem[i].callback,100));
  if(i==1 || i==3) {
   contextMenu.addSeparator();
  }
 }
 map.addContextMenu(contextMenu);
</script>


<script type="text/javascript">
function actchg(obj) {
	chgcity(obj);
	map.centerAndZoom(obj.value, map.getZoom()); 
}

var _room = map.getZoom();
var markernum = 0;
var overlays = [];
function addmarkers(marker) {
	markernum ++;
    overlays[markernum] = marker;
    map.addOverlay(marker);                      //将标注添加到地图中 
    marker.enableDragging();    				 //可拖拽标注
    var label = new BMap.Label(" 我在这里！",{offset:new BMap.Size(20,-10)});
    marker.setLabel(label);//带注释标注
    marker.addEventListener("dragend", function(e){  
    	setmapzb(e.point);
    })  
    marker.addEventListener("click", function(e){
	    //searchInfoWindow.open(marker);
    })
}

function setmapzb(p) {
	_room = map.getZoom();
    var tips = p.lng + "," + p.lat;
	art.dialog.tips('地图标注成功：'+ _room +"|"+ tips);    
	parent.jQuery('#dumappoint').val(_room +"|"+ tips);
}

</script>
</body>
</html>





















